import Router from 'koa-router';
import axios from './utils/axios'
import dbsConfig from '../dbs/config'
import category from '../dbs/models/category'
const {
  sign
} = dbsConfig
const router = new Router({prefix: '/category'})

// 获取分类 地区
router.get('/crumbs', async (ctx) => {
  
  const {types,areas} = await category.model.findOne({
    city: ctx.query.city || '丽江'
  })
  // console.log(types,areas)
  ctx.body = {types,areas}

  // let {status,data:{areas,types}} = await axios.get('http://cp-tools.cn/category/crumbs',{
  //   params:{
  //     city:ctx.query.city.replace('市','') || "北京",
  //     sign
  //   }
  // })
  // ctx.body={
  //   areas: status===200?areas:[],
  //   types: status===200?types:[]
  // }
})


export default router